package com.joysuch.wwyt.bp.entity.inspect;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 巡检-检查记录
 */
@Data
@Entity
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Table(name = "WWYT_BP_INSPECT_RECORD")
@SQLDelete(sql = "update WWYT_BP_INSPECT_RECORD set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BP_INSPECT_RECORD set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
public class BpInspectRecord implements Serializable {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @ApiModelProperty("主键ID")
    private Long id;

    @ApiModelProperty("检查计划ID")
    private Long inspectPlanId;

    @ApiModelProperty("检查计划名称(检查路线)")
    @Transient
    private String inspectPlanName;

    @ApiModelProperty("检查类型")
    @Transient
    private String inspectType;

    @ApiModelProperty("巡检过程")
    @Transient
    private String inspectProcess;

    @ApiModelProperty("异常")
    @Transient
    private Integer exceptionSum;

    @ApiModelProperty("异常处理")
    @Transient
    private String exceptionHandle;

    @ApiModelProperty("检查开始时间")
    private LocalDateTime inspectStartTime;

    @ApiModelProperty("检查完成时间")
    private LocalDateTime inspectFinishTime;

    @ApiModelProperty("巡检用时")
    @Transient
    private String inspectTotalTime;

    @ApiModelProperty("检查人员ID")
    private Long inspectUserId;

    @ApiModelProperty("检查人员姓名-巡检人员")
    @Transient
    private String inspectUserName;

    @ApiModelProperty("填报人员ID")
    private Long fillFormUserId;

    @ApiModelProperty("填报人员姓名")
    @Transient
    private String fillFormUserName;

    @ApiModelProperty("填报时间")
    @DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
    private LocalDateTime fillFormTime;

    @ApiModelProperty("上传方式")
    private String uploadWay;

    @ApiModelProperty("检查结果")
    private String checkResult;

    @ApiModelProperty("路线状态")
    @Transient
    private String routeStatus;

    @ApiModelProperty("检查计划任务表id-APP端才用得到")
    private Long appPlanTaskId;

    @ApiModelProperty("检查过期标志--app端使用 过期 1; 否则 0")
    private Integer expireFlag = 0;

    @ApiModelProperty("app 过期未检标识位")
    private String uncheckStatus;

    @Transient
    @ApiModelProperty("计划开始时间")
    private LocalDateTime planStartTime;

    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    private Long createBy;

    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    private java.time.LocalDateTime createTime;

    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    private Long updateBy;

    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    private java.time.LocalDateTime updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    private String deleteFlag;
}
